package foxmob.mooc.blog;


import spark.Request;
import spark.Response;

import static spark.Spark.get;
import static spark.Spark.post;
import foxmob.mooc.Utils;
import java.util.Date;


/**
 * Created by liyusen on 2017/4/20.
 */
public class BlogAction {
    public static void  init(){
        post("/blog/add", BlogAction::addBlog);


    }
    public static String addBlog(Request req, Response res){
        Date d = new Date();
        String path = "/Users/liyusen/"+ d.getTime()+".pdf";

        String[] values = Utils.getMultipart(
                new String[] {"title","content"},
                req);



        if(Utils.storeFile(req,"file",path)){
            return "{res:0}";
        }


        return "{res:1}";

    }
}
